﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<AgriMarketWebProj.AgriMarketService.Auction>"  %>
<%@ Import Namespace="AgriMarketWebProj.AgriMarketService" %>
<%@ Import Namespace="AgriMarketWebProj.Models" %>
<%@ Import Namespace="System.Web.Script.Serialization" %>
<%@ Import Namespace="System.Web.Helpers" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    AgriMarket|Quản trị đấu giá
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
   <script src="<%: Url.Content("~/Scripts/jquery-1.5.1.min.js") %>" type="text/javascript"></script>
    <script src="<%: Url.Content("~/Scripts/jquery.validate.min.js") %>" type="text/javascript"></script>
    <script src="<%: Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js") %>" type="text/javascript"></script>
    <script src="../../External/DatetimePicker/datetimepicker_css.js" type="text/javascript"></script>
    <script src="../../Scripts/AgriProj/AuctionAdmin/AuctionAdmin.js" type="text/javascript"></script>
    <%List<Product> allProducts = ViewBag.AllProducts; %>
    <%List<TypeOfAuction> allTypes = ViewBag.AllTypeOfAuctions; %>
    <%JavaScriptSerializer serializer = new JavaScriptSerializer(); %>
    <%if (Model != null && allTypes.Count > 0 && allTypes.Count > 0)
      { %>
    <form method="post" action="/AuctionAdmin/Edit" enctype = "multipart/form-data">
        <%: Html.ValidationSummary(false)%>
        <fieldset>
            <legend>Auction</legend>
    
            <%: Html.HiddenFor(model => model.AuctionId)%>
    
            <div class="editor-label">
                Types Of Auction
            </div>
            <div class="editor-field">
                <select name='TypeOfAuctionId'>
                <%
foreach (var type in allTypes)
{
    if (type.TypeId == Model.Type.TypeId)
        Response.Write("<option value='" + type.TypeId + "' selected>" + type.TypeName + "</option>");
    else
        Response.Write("<option value='" + type.TypeId + "' >" + type.TypeName + "</option>");
}
                    
                     %>
                </select>
            </div>
                
            <div class="editor-label">
                <%: Html.LabelFor(model => model.PostedDate)%>
            </div>
            <div class="editor-field">
                <%: Html.EditorFor(model => model.PostedDate)%>
                <img src='../../External/DatetimePicker/images2/cal.gif' onclick='javascript:NewCssCal(&apos;PostedDate&apos;,&apos;&apos;,&apos;ddMMyyyy&apos;,&apos;dropdown&apos;,true,&apos;12&apos;,true)' style='cursor:pointer'/>
                <%: Html.ValidationMessageFor(model => model.PostedDate)%>
            </div>
    
            <div class="editor-label">
                <%: Html.LabelFor(model => model.Topic)%>
            </div>
            <div class="editor-field">
                <%: Html.EditorFor(model => model.Topic)%>
                <%: Html.ValidationMessageFor(model => model.Topic)%>
            </div>
    
            <div class="editor-label">
                <%: Html.LabelFor(model => model.InitialPrice)%>
            </div>
            <div class="editor-field">
                <%: Html.EditorFor(model => model.InitialPrice)%>
<%--                <%: Html.ValidationMessageFor(model => model.InitialPrice) %>--%>
            </div>
    
            <div class="editor-label">
                <%: Html.LabelFor(model => model.ProductDescription)%>
            </div>
            <div class="editor-field">
                <%: Html.TextAreaFor(model => model.ProductDescription)%>
                <%: Html.ValidationMessageFor(model => model.ProductDescription)%>
            </div>
    
            <div class="editor-label">
                <%: Html.LabelFor(model => model.StartedDate)%>
            </div>
            <div class="editor-field">
                <%: Html.EditorFor(model => model.StartedDate)%>
                <img src='../../External/DatetimePicker/images2/cal.gif' onclick='javascript:NewCssCal(&apos;StartedDate&apos;,&apos;&apos;,&apos;ddMMyyyy&apos;,&apos;dropdown&apos;,true,&apos;12&apos;,true)' style='cursor:pointer'/>
                <%: Html.ValidationMessageFor(model => model.StartedDate)%>
            </div>
    
            <div class="editor-label">
                <%: Html.LabelFor(model => model.FinishedDate)%>
            </div>
            <div class="editor-field">
                <%: Html.EditorFor(model => model.FinishedDate)%>
                <img src='../../External/DatetimePicker/images2/cal.gif' onclick='javascript:NewCssCal(&apos;FinishedDate&apos;,&apos;&apos;,&apos;ddMMyyyy&apos;,&apos;dropdown&apos;,true,&apos;12&apos;,true)' style='cursor:pointer'/>
                <%: Html.ValidationMessageFor(model => model.FinishedDate)%>
            </div>
    
            <div class="editor-label">
                <%: Html.LabelFor(model => model.ProductImage)%>
            </div>
            <div class="editor-field">
                <%="<input type='hidden' name='ProductImageName' value='" + Model.ProductImage + "'/>"%>
                <div name='ProductImageDiv' id='ProductImageDiv'>
                <%= "<img src='" + ServiceURL.ServicePath + Model.ProductImage + "' width=200px />"%>
                </div>
                <input type="file" name='ProductImageFile' id='ProductImageFile' />
            </div>
            <div class="editor-label">
                Product
            </div>
            <div class="editor-field">
                    <select name="ProductId" id="ProductId">
                        <%
foreach (var product in allProducts)
{
    if (product.ProductId == Model.Product.ProductId)
        Response.Write("<option value='" + product.ProductId + "' selected>" + product.ProductName + "</option>");
    else
        Response.Write("<option value='" + product.ProductId + "' >" + product.ProductName + "</option>");
}
                        %>
                    </select>
            </div>
            <div class="editor-label">
                <%: Html.LabelFor(model => model.AuthorId)%>
            </div>
            <div class="editor-field">

                <%: Html.EditorFor(model => model.AuthorId)%>
                <%: Html.ValidationMessageFor(model => model.AuthorId)%>
            </div>
            <p>
                <input type="submit" value="Save" />
            </p>
        </fieldset>
    </form>
    <%} %>
    <div>
        <%: Html.ActionLink("Back to List", "Index") %>
    </div>
         
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
</asp:Content>

